
***** Table H.9	
use "$datadir\ewallet\maindata.dta", clear
	bys time: egen exposure_5 = xtile(invshare_sd), nq(3)
	keep if time == 201610
	keep exposure_5 invshare_sd min_distance_hub_500 distance_capital district state district_id  state_id large_metro_area threshold_merchants_1000 NE_states_1 share_rural logpop_T l_preshockdeposit201604 s_status_atm s_status_commercialbank
save "$datadir\temp.dta", replace

use "$datadir\ewallet\merchants_reshape_week_withnumfirms.dta" , clear		
		
	
	****** 3 policy weeks
	keep if (time >= 28 & time <= 30) | (time >= 32 & time <= 34) | (time >= 36 & time <= 38)
	
	g event = 1 if (time >= 28 & time <= 30)
	replace event = 2 if (time >= 32 & time <= 34)
	replace event = 3 if (time >= 36 & time <= 38)
	
	**** attach exposure measure
	merge m:1 district state using "$datadir\temp.dta" 
	keep if _m == 3
	drop _m
	
	foreach var in  transaction  {
		g base`var' = `var' if time == 28 | time == 32 | time == 36 
		bys state district event: egen x = max(base`var')
		replace base`var' = x 
		drop x 
		g delta`var' = (`var'-base`var')/((base`var'+`var')*0.5)
		replace delta`var' = 0 if delta`var' == . & base`var' == 0 
	}

	local depvar deltatransaction
	reg `depvar' invshare_sd share_rural logpop_T l_preshockdeposit201604 s_status_atm s_status_commercialbank if time == 30 , cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_9.tex", tex(frag) ctitle(" November 8, 2016 ") keep(invshare_sd) dec(3) bracket label addtext(District Controls , $\checkmark$ ) nocons nonotes stats(coef se) replace
	reg `depvar' invshare_sd share_rural logpop_T l_preshockdeposit201604 s_status_atm s_status_commercialbank if time == 34 , cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_9.tex", tex(frag) ctitle(" December 8, 2016 ") keep(invshare_sd) dec(3) bracket label addtext(District Controls , $\checkmark$ ) nocons nonotes stats(coef se) append
	reg `depvar' invshare_sd share_rural logpop_T l_preshockdeposit201604 s_status_atm s_status_commercialbank if time == 38 , cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_9.tex", tex(frag) ctitle(" January 1, 2017 ") keep(invshare_sd) dec(3) bracket label addtext(District Controls , $\checkmark$ ) nocons nonotes stats(coef se) append

	cap erase "$datadir\temp.dta"
